<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta http-equiv="Cache-Control" content="No-Cache">
	<meta http-equiv="Pragma" content="No-Cache">

	<title>우편번호 검색</title>
	
	<link rel="stylesheet" type="text/css" href="/css/common.css" />
	<link rel="stylesheet" type="text/css" href="/css/mypage.css"/>

	<link href="/css/lib/myconfig.jquery.validate.css" rel="stylesheet" type="text/css"/>
	
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
	<script src="/js/lib/jquery.validate.min.js" type="text/javascript"></script>
	<script src="/js/utility/common_util.js" type="text/javascript"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$(function(){
				//resizePopup($(".pop"));
			});

			$(".result dl:first").addClass('first');
			$(".result dl:last").addClass('end');

			$("#frm").validate({
				rules: {
					search_string: {
					 	required: true,
					 	minlength: 2
					 }
				},
				messages: {
					search_string: {
						required: "검색어를 입력해 주세요.",
						minlength: "2자리 이상 입력하세요.",
					}
				},
				submitHandler: function(form) {
					form.submit();
				}
			});
			
			$("#btnSearch").click(function() {
				$("#frm").submit();
			});
		});
	</script>

	<script type="text/javascript">
		function find_zip(zipcode, addr) {
			var of = opener.document.forms[0];
	
			of.zip_code.value  = zipcode;
			of.addr1.value = addr;
			
			of.addr2.focus();
			window.close();
			return false;
		}
	</script>
</head>

<body>
<div id="wrap">
	<div class="pop">
		<form name="frm" id="frm" method="get" action="/member/zipcode" autocomplete="off">
			<fieldset>
				<legend>우편번호 검색</legend>
				<h1><img src="/images/member/ptit_zipcode.png" alt="우편번호검색" /></h1>
				<p class="zigline"></p>
				<!--서브타이틀-->
				<div class="contents">
					<div class="zipcode">
						<p class="popText">* 찾고자 하시는 주소의 동(읍/면/리)을 입력하세요.<br />예) 수유,두리,무지(두글자 이상)</p>
						<div class="box2">
							<p>
								<em>동(읍/면/리)</em>
								<input type="text" size="20" name="search_string" id="search_string" value="<?=$search_string;?>" title="찾고자 하시는 주소의 동(읍/면/리)을 입력하세요." class="inpText" />
								<a href="javascript:;" id="btnSearch"><img src="/images/common/bt_seach.png" alt="검색" align="absmiddle" /></a><br>
								<label class="error" for="search_string" generated="true"></label>
							</p>
						</div><!--box2-->
<?	if (isset($zipcode_list) && count($zipcode_list) > 0) : ?>
						<!--우편번호가 검색 되었을시-->
						<div class="result">
							<span class="text">총<em><?=count($zipcode_list);?>건</em>이 검색되었습니다.</span>
<?		foreach ($zipcode_list as $item) : ?>
							<dl>
								<dt><span><?=substr($item['zipcode'], 0,3);?></span>-<span><?=substr($item['zipcode'], 3,6);?></span></dt>
								<dd class="adres"><?=$item['address_full'];?></dd>
								<dd class="bt_select"><a href="javascript:;" onclick="find_zip('<?=substr($item['zipcode'], 0,3).'-'.substr($item['zipcode'], 3,6);?>', '<?=$item['addr'];?>');"><img src="/images/common/bt_slect.png" alt="선택하기" /></a></dd>
							</dl>
<?		endforeach ?>
						</div><!--result-->
						<!--//우편번호가 검색 되었을시-->
<?	elseif (!empty($search_string)): ?>
						<!--우편번호가 검색되지 안되었을시-->
						<div class="result_no">
							<span class="text_no">조건에 맞는 주소가 없습니다.<br/>다시 확인해주세요.</span>
						</div><!--result-->
						<!--//우편번호가 검색되지 안되었을시-->
<?	endif ?>
					</div>
				</div>
			</fieldset>
		</form>
		<!--하단--> 
	</div>
	<!--pop--> 
</div>
<!--전체-->

</body>
</body>
</html>
